package com.sky.mapper;

import com.sky.entity.OrderDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface OrderDetailMapper {
    void addBatch(List<OrderDetail> orderDetailList);

    @Select("select * from order_detail where order_id=#{id}")
    List<OrderDetail> getByOrderId(Long id);

    /*
    * 统计销量前十菜品
    * */
    @Select("select name,sum(number) as number from order_detail where order_id " +
            "in (select id from orders where checkout_time >= #{beginTime}  and checkout_time<=#{endTime} and status=5)" +
            "group by name " +
            "order by number desc  limit 0,10")
    List<OrderDetail> getGoodsList(LocalDateTime beginTime, LocalDateTime endTime);
}
